<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Spring Boot开发平台</title>
    <link rel="stylesheet" href="${ctxPath}/plugins/layui/css/layui.css">
    <script src="${ctxPath}/plugins/layui/layui.js"></script>
  
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style rel="stylesheet" type="text/css">
        .layui-tab-title li:first-child > i {
            display: none;
        }
    </style>
</head>
<body class="layui-layout-body" >
<!--<body class="layui-layout-body" onload="aaa()"><-->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>用户登录</legend>
</fieldset>
 <div style="position:absolute;top: 35%;left: 38%;right:20%;bottom:30%;height: 200px;width: 400px">
<form class="layui-form" id="form"  action="${ctxPath}/login.do" method="post">
  <div class="layui-form-item">
    <label class="layui-form-label">用户名</label>
    <div class="layui-input-inline">
      <input type="text" name="code" id="code" lay-verify="title" autocomplete="off"
      	placeholder="请输入用户名" class="layui-input"  value="admin">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-inline">
      <input type="password" name="password" id="password" lay-verify="required"  name="" placeholder="请输入密码" autocomplete="off"
       class="layui-input" value="123456">
    </div>
  </div>
    <div class="layui-form-item">
        <label class="layui-form-label">机构</label>
        <div class="layui-input-inline">
            <input type="text" name="orgId" id="orgId" lay-verify="required"  name="" placeholder="请输入密码" autocomplete="off"
                   class="layui-input" value="1">
        </div>
    </div>
  </form>
     <div class="layui-form-item">
         <div class="layui-input-block">
             <button class="layui-btn" onclick="check()">立即登录</button>

         </div>
     </div>
 </div>
<script type="text/javascript">
    function check()
    {
        var xmlhttp;
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function()
        {
            if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
                var error = xmlhttp.responseText;
                if(error=="0"){
                    var form =document.getElementById("form");
                    form.submit();
                }else if(error=="1"){
                    alert("用户不存在");
                }else if(error=="2"){
                    alert("用户密码错误");
                }else if(error=="3"){
                    alert("用户已经被锁定");
                }else if(error=="4"){
                    alert("用户已经失效");
                }else if(error=="5"){
                    alert("用户已经删除");
                }else if(error=="6"){
                    alert("用户与管理机构不一致");
                }else if(error=="7"){
                    alert("用户不在生效日期范围内");
                }
            }
        }


        var code = document.getElementById("code").value;
        var password = document.getElementById("password").value;
        var orgId = document.getElementById("orgId").value;
        var param = code+","+password+","+orgId+","
        var URL="${ctxPath}/check.do";
        xmlhttp.open("POST",URL,true);
        xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        xmlhttp.send("param="+param);
    }
</script>
</body>
</html>